<? 
//checking for customer loged or not - this is restriction script
require_once("admin/dbconnect.php");
require_once("admin/classes/check_customer_session.php");
check_customer_session(); 
require_once('admin/classes/PaginateIt.php'); 
$PaginateIt = new PaginateIt();
$PaginateIt->SetItemsPerPage(10);
$PaginateIt->SetLinksToDisplay(8);
$PaginateIt->SetLinksFormat( '<< Previous', '  ', 'Next >>' );

$PaginateIt->SetQueryString("con=".$conn);

session_start();

if($_GET['action'] == "DELETE")
{
	$query_data = "Update scrap set is_deleted='1' where scrap_id=".$_REQUEST['sid'];
	$result_update	= mysql_query ( $query_data ) or die(mysql_error());
}

if($_GET['action'] == "CANCEL")
{
	$query_data = "Update scrap set approve='C' where scrap_id=".$_REQUEST['sid'];
	$result_update	= mysql_query ( $query_data ) or die(mysql_error());
}

if($_GET['action'] == "APPROVE")
{
	$query_data = "Update scrap set approve='Y' where scrap_id=".$_REQUEST['sid'];
	$result_update	= mysql_query ( $query_data ) or die(mysql_error());
}

if($_GET['action'] == "SPAM")
{
	$query_data = "Update scrap set spam='1' where scrap_id=".$_REQUEST['sid'];
	$result_update	= mysql_query ( $query_data ) or die(mysql_error());
}

					$cid = $_SESSION['ep_customer_id'];
					$sql = "SELECT customer.customer_id, customer.name, customer.surname, scrap.scrap_id, scrap.scrap, customer.image_1 FROM scrap INNER JOIN customer ON scrap.from = customer.customer_id WHERE scrap.to = $cid";
						$sql.= " and customer.status = 'Y' and scrap.approve != 'N' and scrap.approve != 'C' and spam != 1 and is_deleted !=1";
						$sql.= " ORDER by scrap.scrap_id ASC";
					
					$rs = mysql_query($sql) or die(mysql_error());
					$cnt = mysql_num_rows($rs);
					$sql .= $PaginateIt->GetSqlLimit();
					$rs = mysql_query($sql) or die(mysql_error());
				

?>


<?php require_once('include/header.php'); ?>


      <div id="middle_container_for_innerpage">
      <div id="innerpage_top_image"><img src="images/images/innerpage_top_corner_820x5.jpg"  height="5" /></div> 
      <div id="middle_inner_container">
      <?php require_once('include/left_menu.php'); ?>
        
        <div id="inner_page_middle_data">
        	<div id="page_heading">Received Messages</div>
            <div id="sended_msg_row">
            	
            </div>
            <div id="sended_msg_row">
            	
            </div>
			 
           
            <div id="sended_msg_row">
            	<p>Total messages received: <?=$cnt?></p>
                <p>New messages received: [messages count]</p>
                <p></p>
            </div>
			<div id="sended_headings">
            	<div id="msg_head_from">Received From</div>
                <div id="msg_head_details">Message</div>
                <div id="msg_head_app_del">Response</div>
            </div>
			<?
					if(@mysql_num_rows($rs)>0){
				?>
				<?	while($row=mysql_fetch_array($rs)){ ?>
				 
            <div id="sended_details">
            	<div id="sended_image_other">
                	<div id="sended_image"><?if($row['image_1']){?><a href="profile.php?cid=<?php echo $row['customer_id']; ?>"><img src="uploaded/thumb/<?=$row['image_1']?>"  border="0" class="image_border"></a>
                  <?}else{?>
                <a href="profile.php?cid=<?php echo $row['customer_id']; ?>"><?if($row['gender']=="Male"){?><img src="images/images/default_eparinay_groom.jpg" width="90" height="90" border="0" class="image_border" ><?} else{?>
				<img src="images/images/default_eparinay_bride.jpg" width="90" height="90" border="0" class="image_border" ><?}?></a>                <?}?></div>
                	<div id="sended_other">
                    	<div id="sended_id">ID: <a href="profile.php?cid=<?=$row['customer_id']?>"><?=$row['customer_id']?></a></div>
                    	<div id="sended_id">Received Message from: <?=$row['name']?></div>						
                		<div id="sended_name">Sender:  <?=$_SESSION['ep_customer_name']?>             		    </div>
                		<div id="sended_date">Date: <?=$row['created_at']?></div>
                		<!--<div id="sended_from"> Location: </div>-->
                        <!--<div id="sended_email">amolnw2778@gmail.com</div>-->
                    </div>
                </div>
                <div id="sended_message_detailed"><?=$row['scrap']?></div>
              <div id="sended_links">
                	<span class="green"><strong>&radic;</strong></span> <a href="JavaScript:if(confirm('Are you sure you want to approve this Customer?')){self.location.href='sended_messages.php?sid= <?=$row['scrap_id']; ?>&action=APPROVE';}" class="link-normal">Approve</a><br />
                	<span class="red-txt"><strong>&Oslash;</strong></span> <a href="JavaScript:if(confirm('Are you sure you want to Delete this Customer?')){self.location.href='sended_messages.php?sid=<?=$row['scrap_id']; ?>&action=CANCEL';}" class="link-normal">Cancel</a><br />
                    <span class="red-txt"><strong>&chi;</strong></span> <a href="JavaScript:if(confirm('Are you sure you want to approve this Customer?')){self.location.href='sended_messages.php?sid= <?=$row['scrap_id']; ?>&action=DELETE';}" class="link-normal">Delete</a><br />
                  <span class="red-txt"><strong>&Delta;</strong></span> <a href="JavaScript:if(confirm('Are you sure you want to approve this Customer?')){self.location.href='sended_messages.php?sid= <?=$row['scrap_id']; ?>&action=SPAM';}" class="link-normal">Spam</a>                </div>
            </div><? }} else {?>
			
            <div id="sorry_text">Sorry !! No results found.</div><?}?>
            <div >
            	<? if ($cnt > 11) {?>
                    <? echo $PaginateIt->GetPageLinks(); ?>  <? } ?>
                    <!--pagecount table starts here-->
                    
                
            </div>
		</div>
        

       
       
      </div> 
      <div id="corner_container_bottom_for_innerpage"><img src="images/images/innerpage_bottom_corner_820x10.jpg"  height="10" /></div>
    </div> 
      <!-- middle_container ends -->
    
    
        
    
<?php require_once('include/footer.php'); ?>
